<?php
	echo "<h1>Pending Group Invitations</h1>";
	echo "<p>You have " . checkInvites($_SESSION['username']) . " current group invitation/s. Please select an option to join or remove an invitation.</p>";
	echo "<p>Note: you can only join one group.</p>";
	
	$invites = getInvites($_SESSION['username']);
	
	echo "<div id=\"groupInvite\">";
	while ($row = mysql_fetch_array($invites)) {
		$name = getUserName($row[1]);
		$address = getAddress($row[0]);
		
		echo "<fieldset>";
		echo "<p>" . $name[0] . " " . $name[1] . " (" . $row[1] . ") has invited you to a Flatshare Group located at:</p><p>";
		if ($address[0] != NULL && $address[0] > 0) { //check for unit number
			echo "Unit " . $address[0] . ", ";
		}
		echo $address[1] . " " . $address[2] . " " . $address[3] . "<br/>" . $address[4] . " " . $address[5] . "</p>";
		echo "<form name=\"inviteForm\" id=\"inviteForm\" method=\"post\" action=\"?group_invites&invitation\"><input type =\"hidden\" id=\"groupid\" name=\"groupid\" value=\"" . $row[0] . "\" /><input type=\"submit\" name=\"join\" value=\"Join\"><input type=\"submit\" name=\"remove\" value=\"Remove\"></form>";
		echo "</fieldset>";
		echo "<br/>";
	}
	echo "</div>";
?>